﻿using System;
using System.Collections.ObjectModel;
using Moq;
using Prompts.PromptServiceProxy;
using Prompts.Service.PromptService;

namespace Test.Prompts.Infrastructure.Fakes
{
    internal class FakePromptSelectionServiceClient
    {
        private readonly Mock<IPromptSelectionService2Client> _mock;
        private Action<SetPromptSelectionsResponse> _callback;

        public FakePromptSelectionServiceClient()
        {
            _mock = new Mock<IPromptSelectionService2Client>();
        }

        public void SetupSetPromptSelections(string path, ObservableCollection<PromptSelectionInfo> promptSelections)
        {
            var setup = _mock.Setup(m => m.SetPromptSelectionsAsync(
                path,
                promptSelections,
                It.IsAny<Action<SetPromptSelectionsResponse>>()));

            setup.Callback<
                string,
                ObservableCollection<PromptSelectionInfo>,
                Action<SetPromptSelectionsResponse>>(
                    (p, ps, response) => _callback = response);
        }

        public void CallbackWith(SetPromptSelectionsResponse setPromptSelectionsResponse)
        {
            _callback(setPromptSelectionsResponse);
        }

        public IPromptSelectionService2Client Object
        {
            get { return _mock.Object; }
        }
    }
}
